import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class ToolService {

constructor() { }
// 过滤对象的英文字段
// 返回过滤好的对象
filterEnlishProperty(detail) {
  const obj = {};
  Object.keys(detail).forEach(i => {
    if (!(/^[a-zA-Z]+$/.test(i))) {
      obj[i] = detail[i];
    }
  });
  return obj;
}
 // 节流防抖函数
 throttle(fn, space) {
  let task = null;
  return () => {
    if (!task) {
      task = setTimeout(function() {
        task = null;
        fn.apply(this, arguments);
      }, space);
    }
  };
}
}
